package cn.itcast.hotel.listen;

import cn.itcast.hotel.constants.MqConstants;
import cn.itcast.hotel.service.IHotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class HotelListener {
    @Autowired
    IHotelService hotelService;
    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    public void listenInsertMsg(Long hotelId) {
        log.info("接收到更新酒店消息通知  id{}",hotelId);
        hotelService.insert(hotelId);

    }

    @RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)
    public void listenDeleteMsg(Long hotelId) {
        log.info("接收到删除酒店消息通知  id{}",hotelId);
        hotelService.delete(hotelId);

    }


}
